package com.ljw.miniweb.board.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Repository;


import com.ibatis.sqlmap.client.SqlMapClient;
import com.ljw.miniweb.board.bean.BoardBean;
import com.ljw.miniweb.dbconn.MyAppSqlConfig;

@Repository("boardDao")
public class BoardDaoImpl implements BoardDao{
	
	Log logger = LogFactory.getLog(this.getClass());
	SqlMapClient sqlMap = MyAppSqlConfig.getSqlMapInstance();
	
	@Override
	public ArrayList getBoardList() throws SQLException {
		ArrayList<BoardBean> list = (ArrayList<BoardBean>)sqlMap.queryForList("getBoardList");
		
		BoardBean bean = new BoardBean();
		
		for(int i = 0; i < list.size(); i++){
			bean = list.get(i);
			logger.info("seq = " + bean.getBoard_seq() );
			logger.info("content = " + bean.getContent() );
		}
		return list;
	}

	@Override
	public int getPageCount() throws SQLException {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void insertBoard(BoardBean bean) throws SQLException {
		sqlMap.insert("insertBoard", bean);
		
	}
	
	
	
}
